package com.kjlink.internal.workreport.company.controller;

import cn.xuqiudong.common.base.controller.BaseController;
import cn.xuqiudong.common.base.model.BaseResponse;
import cn.xuqiudong.common.base.vo.Select2VO;
import cn.xuqiudong.common.util.CommonUtils;
import com.kjlink.internal.workreport.company.model.Company;
import com.kjlink.internal.workreport.company.service.CompanyService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能: :公司 控制层
 *
 * @author Vic.xu
 * @since 2024-04-29 13:40
 */
@RestController
@RequestMapping("/company")
public class CompanyController extends BaseController<CompanyService, Company> {


    /**
     * 全部的公司
     */
    @RequestMapping(value = "all")
    public BaseResponse<List<Select2VO>> all() {
        Company lookup = new Company();
        lookup.setEnable(true);
        List<Company> list = service.list(lookup);
        List<Select2VO> result = CommonUtils.listFilter(list, tag -> new Select2VO(tag.getId(), tag.getName()));
        return BaseResponse.success(result);
    }

}
